package com.wyzz.hr.util;

import java.util.Date;
import java.util.List;

import com.wyzz.hr.bo.ILeavecalendarBO;
import com.wyzz.hr.pojo.Employee;
import com.wyzz.hr.spring.SpringBeanFactory;

public class DateVarDef {

	public DateVarDef(Employee emp, Date dateArr[], Integer joinYearCalc,
			List lcList) {
		B0Y = Double.valueOf(0.0D);
		B0M = Double.valueOf(0.0D);
		B1Y = Double.valueOf(0.0D);
		B1M = Double.valueOf(0.0D);
		B1J = Double.valueOf(0.0D);
		B1C = Double.valueOf(0.0D);
		B1 = Double.valueOf(0.0D);
		B2 = Double.valueOf(0.0D);
		B3 = Double.valueOf(0.0D);
		B4 = Double.valueOf(0.0D);
		B5 = Double.valueOf(0.0D);
		B6 = Double.valueOf(0.0D);
		B7 = Double.valueOf(0.0D);
		B11 = Double.valueOf(0.0D);
		B12 = Double.valueOf(0.0D);
		B13 = Double.valueOf(0.0D);
		B14 = Double.valueOf(0.0D);
		B15 = Double.valueOf(0.0D);
		B16 = Double.valueOf(0.0D);
		B17 = Double.valueOf(0.0D);
		if (emp == null || dateArr == null)
			return;
		lc_BO = (ILeavecalendarBO) SpringBeanFactory.getBean("leavecalendarBO");
		Double workYear;
		if (emp.getEmpWorkDate() != null) {
			workYear = MyTools.getWorkYearSalary(emp.getEmpWorkDate(),
					dateArr[1], joinYearCalc);
			setB0Y(Double.valueOf(workYear.intValue()));
			setB0M(Double.valueOf(workYear.doubleValue() * 100D
					- (double) (workYear.intValue() * 100)));
		}
		workYear = MyTools.getWorkYearSalary(emp.getEmpJoinDate(), dateArr[1],
				joinYearCalc);
		setB1Y(Double.valueOf(workYear.intValue()));
		setB1M(Double.valueOf(workYear.doubleValue() * 100D
				- (double) (workYear.intValue() * 100)));
		lc_BO = (ILeavecalendarBO) SpringBeanFactory.getBean("leavecalendarBO");
		setB1(new Double(lc_BO.getWorkDays(dateArr[0], dateArr[1], lcList, emp
				.getEmpLocationNo())));
		setB11(new Double(DateUtil.dateDiff(dateArr[0], dateArr[1], 5) + 1));
		Date thisYearEnd = DateUtil.dateTimeAdd(dateArr[1], 1, 1);
		if (emp.getEmpTerminateDate() != null
				&& emp.getEmpTerminateDate().compareTo(dateArr[1]) > 0
				&& emp.getEmpTerminateDate().compareTo(thisYearEnd) < 0)
			thisYearEnd = emp.getEmpTerminateDate();
		Date joinDateBegin = emp.getEmpJoinDate();
		if (emp.getEmpJoinDate().compareTo(dateArr[1]) <= 0)
			joinDateBegin = DateUtil.dateAdd(dateArr[1], 1);
		workYear = MyTools.getWorkYearSalary(joinDateBegin, thisYearEnd,
				joinYearCalc);
		setB1J(Double.valueOf(workYear.doubleValue() * 100D
				- (double) (workYear.intValue() * 100)));
		if (emp.getEmpConfirmDate() != null) {
			Date confDateBegin = emp.getEmpConfirmDate();
			if (emp.getEmpConfirmDate().compareTo(dateArr[1]) <= 0)
				confDateBegin = DateUtil.dateAdd(dateArr[1], 1);
			workYear = MyTools.getWorkYearSalary(confDateBegin, thisYearEnd,
					joinYearCalc);
			setB1C(Double.valueOf(workYear.doubleValue() * 100D
					- (double) (workYear.intValue() * 100)));
		}
		if (emp.getEmpConfirmDate() == null
				|| emp.getEmpConfirmDate().compareTo(dateArr[1]) > 0) {
			setB3(B1);
			setB13(B11);
		} else if (emp.getEmpConfirmDate().compareTo(dateArr[0]) > 0
				&& emp.getEmpConfirmDate().compareTo(dateArr[1]) <= 0) {
			setB3(new Double(lc_BO.getWorkDays(dateArr[0], emp
					.getEmpConfirmDate(), lcList, emp.getEmpLocationNo()) - 1));
			if (B3.doubleValue() < 0.0D)
				setB3(new Double(0.0D));
			setB4(new Double(lc_BO.getWorkDays(emp.getEmpConfirmDate(),
					dateArr[1], lcList, emp.getEmpLocationNo())));
			setB13(new Double(DateUtil.dateDiff(dateArr[0], emp
					.getEmpConfirmDate(), 5)));
			setB14(new Double(DateUtil.dateDiff(emp.getEmpConfirmDate(),
					dateArr[1], 5) + 1));
		} else {
			setB4(B1);
			setB14(B11);
		}
		if (emp.getEmpJoinDate().compareTo(dateArr[0]) > 0
				&& emp.getEmpJoinDate().compareTo(dateArr[1]) <= 0) {
			setB6(new Double(lc_BO.getWorkDays(dateArr[0],
					emp.getEmpJoinDate(), lcList, emp.getEmpLocationNo()) - 1));
			if (B6.doubleValue() < 0.0D)
				setB6(new Double(0.0D));
			setB16(new Double(DateUtil.dateDiff(dateArr[0], emp
					.getEmpJoinDate(), 5)));
			setB3(Double.valueOf(B3.doubleValue() - B6.doubleValue()));
			setB13(Double.valueOf(B13.doubleValue() - B16.doubleValue()));
		}
		if (emp.getEmpTerminateDate() != null
				&& emp.getEmpTerminateDate().compareTo(dateArr[0]) >= 0
				&& emp.getEmpTerminateDate().compareTo(dateArr[1]) < 0) {
			setB7(new Double(lc_BO.getWorkDays(emp.getEmpTerminateDate(),
					dateArr[1], lcList, emp.getEmpLocationNo()) - 1));
			if (B7.doubleValue() < 0.0D)
				setB7(new Double(0.0D));
			setB17(new Double(DateUtil.dateDiff(emp.getEmpTerminateDate(),
					dateArr[1], 5)));
			setB3(Double
					.valueOf(B4.doubleValue() - B7.doubleValue() >= 0.0D ? B3
							.doubleValue() : (B3.doubleValue() + B4
							.doubleValue())
							- B7.doubleValue()));
			setB13(Double
					.valueOf(B14.doubleValue() - B17.doubleValue() >= 0.0D ? B13
							.doubleValue()
							: (B13.doubleValue() + B14.doubleValue())
									- B17.doubleValue()));
			setB4(Double
					.valueOf(B4.doubleValue() - B7.doubleValue() >= 0.0D ? B4
							.doubleValue()
							- B7.doubleValue() : 0.0D));
			setB14(Double
					.valueOf(B14.doubleValue() - B17.doubleValue() >= 0.0D ? B14
							.doubleValue()
							- B17.doubleValue()
							: 0.0D));
		}
		setB2(Double.valueOf(B3.doubleValue() + B4.doubleValue()));
		setB12(Double.valueOf(B13.doubleValue() + B14.doubleValue()));
		setB5(Double.valueOf(B6.doubleValue() + B7.doubleValue()));
		setB15(Double.valueOf(B16.doubleValue() + B17.doubleValue()));
	}

	public Double getB1J() {
		return B1J;
	}

	public void setB1J(Double b1j) {
		B1J = b1j;
	}

	public Double getB1C() {
		return B1C;
	}

	public void setB1C(Double b1c) {
		B1C = b1c;
	}

	public Double getB1Y() {
		return B1Y;
	}

	public void setB1Y(Double b1y) {
		B1Y = b1y;
	}

	public Double getB1M() {
		return B1M;
	}

	public void setB1M(Double b1m) {
		B1M = b1m;
	}

	public Double getB0M() {
		return B0M;
	}

	public void setB0M(Double b0m) {
		B0M = b0m;
	}

	public Double getB0Y() {
		return B0Y;
	}

	public void setB0Y(Double b0y) {
		B0Y = b0y;
	}

	public Double getB1() {
		return B1;
	}

	public void setB1(Double b1) {
		B1 = b1;
	}

	public Double getB11() {
		return B11;
	}

	public void setB11(Double b11) {
		B11 = b11;
	}

	public Double getB12() {
		return B12;
	}

	public void setB12(Double b12) {
		B12 = b12;
	}

	public Double getB13() {
		return B13;
	}

	public void setB13(Double b13) {
		B13 = b13;
	}

	public Double getB14() {
		return B14;
	}

	public void setB14(Double b14) {
		B14 = b14;
	}

	public Double getB15() {
		return B15;
	}

	public void setB15(Double b15) {
		B15 = b15;
	}

	public Double getB16() {
		return B16;
	}

	public void setB16(Double b16) {
		B16 = b16;
	}

	public Double getB17() {
		return B17;
	}

	public void setB17(Double b17) {
		B17 = b17;
	}

	public Double getB2() {
		return B2;
	}

	public void setB2(Double b2) {
		B2 = b2;
	}

	public Double getB3() {
		return B3;
	}

	public void setB3(Double b3) {
		B3 = b3;
	}

	public Double getB4() {
		return B4;
	}

	public void setB4(Double b4) {
		B4 = b4;
	}

	public Double getB5() {
		return B5;
	}

	public void setB5(Double b5) {
		B5 = b5;
	}

	public Double getB6() {
		return B6;
	}

	public void setB6(Double b6) {
		B6 = b6;
	}

	public Double getB7() {
		return B7;
	}

	public void setB7(Double b7) {
		B7 = b7;
	}

	private Double B0Y;
	private Double B0M;
	private Double B1Y;
	private Double B1M;
	private Double B1J;
	private Double B1C;
	private Double B1;
	private Double B2;
	private Double B3;
	private Double B4;
	private Double B5;
	private Double B6;
	private Double B7;
	private Double B11;
	private Double B12;
	private Double B13;
	private Double B14;
	private Double B15;
	private Double B16;
	private Double B17;
	private ILeavecalendarBO lc_BO;
}
